﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using Convertor.Interface;
using Wpf.CommonTools.SystemExtension;

namespace Convertor.Plugin.Sort
{
    [Serializable]
    public class ConfigContent : IConfigContent, ISerializable, ICloneable, INotifyPropertyChanged
    {
        private SortTypes sortType = SortTypes.Alphabet;

        public SortTypes SortType
        {
            get { return sortType; }
            set { sortType = value; if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("ToolTip")); } }
        }

        public ConfigContent()
        {
        }

        public override string ToString()
        {
            return ToolTip;
        }

        #region IToolTip 成员

        public string ToolTip
        {
            get
            {
                return string.Format(UILanguage.TryFindResource("Plugin_Sort_Info"),
                    UILanguage.TryFindResource("Plugin_Sort_" + SortType));
            }
        }

        #endregion

        #region ISerializable 成员

        public void GetObjectData(SerializationInfo info, StreamingContext context)
        {
            info.AddValue("SortType", SortType, typeof(SortTypes));
        }

        public ConfigContent(SerializationInfo info, StreamingContext context)
        {
            sortType = (SortTypes)info.GetValue("SortType", typeof(SortTypes));
        }

        #endregion

        #region ICloneable 成员

        public object Clone()
        {
            ConfigContent a = new ConfigContent()
            {
                SortType = this.SortType
            };
            return a;
        }

        #endregion

        #region INotifyPropertyChanged 成员

        public event PropertyChangedEventHandler PropertyChanged;

        #endregion
    }

    public enum SortTypes
    {
        Reverse = 1,
        Alphabet = 2,
        Length = 4
    }

}
